package cn.zz.veggie.web.types.dto.mgmt.settle;

import java.time.ZonedDateTime;

import com.fasterxml.jackson.annotation.JsonIgnore;

import cn.zz.comm.util.DateUtil;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import lombok.Getter;
import lombok.Setter;

/**
 * @author zhongq
 * @since 2024/7/28
 */
@Getter
@Setter
public class MgmtSettleCreateDto {
	@NotNull
	@Positive
	private Integer shopId;

	@NotNull
	@Positive
	private Long statTime;

	@JsonIgnore
	private Long statTimeEnd;

	public void requireValid() {
		ZonedDateTime time = DateUtil.zonedDateTime(statTime).withMonth(1).withHour(0).withSecond(0).withMinute(0);
		statTime = time.toEpochSecond();
		statTimeEnd = time.plusMonths(1).toEpochSecond();
	}

}